# Write a function that takes two parameters.
# Both of them are non-empty array of integers.

# smallest = INIFITY
# smallestPair = []
#
# [-1, 3, 5, 10, 20, 28]
#                        ^idx_one
# [15, 17, 26, 134, 135]
#              ^idx_two

# while idxOne < len(arrayOne) and idxTwo < len(arrayTwo):
# firstNum = -1
# secondNum = 15

# if firstNum < secondNum:
#   current = secondNum - firstNum
#   idxOne += 1
# elif firstNum > secondNum:
#   current = firstNum - secondNum
#   idxTwo += 1
# else: 
#   return [furstNum, secondNum]

# current = 16

# if smallest > current:
#   smallest = current
#   smallestPair = [firstNum, secondNum]



# Return [28, 26]

# Find the pair of numbers whose absolute difference is closest to zero.
# Parameter:
# - arrayOne
# - arrayTwo
# Return:
# - the pair of numbers whose absolute difference is closest to zero.
def smallest_difference(array_one, array_two):
  array_one.sort()
  array_two.sort()

  idx_one = 0
  idx_two = 0

  smallest = float("inf") # infinity
  current = float("inf")
  smallest_pair = []

  while idx_one < len(array_one) and idx_two < len(array_two):
    first_num = array_one[idx_one]
    second_num = array_two[idx_two]

    if first_num < second_num:
      current = second_num - first_num
      idx_one += 1
    elif first_num > second_num:
      current = first_num - second_num
      idx_two += 1
    else:
      return [first_num, second_num]
    
    if smallest > current:
      smallest = current
      smallest_pair = [first_num, second_num]
  
  return smallest_pair

print(smallest_difference([-1, 3, 5, 10, 20, 28], [15, 17, 26, 134, 135]))